home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-17 | 10.9 KB | 303 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: Select.Lib
- #
- # Contains: xxx put contents here xxx
- #
- # Written by: Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
- #
- # Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <1.0.3> 12/2/93 KTA PointSelect() now reports that it performs a click.
- # <1+> 5/21/93 NAGA Adding header and porting old files to follow new standards
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "UserInterface.Lib";
-
- #########################################################################
- # SelectModule.vu
- #========================================================================
- # Description: This module contains VU code for selecting items.
- # All of the Tasks in this module assume that the select
- # tool has already been selected. The library Tasks in
- # this module are grouped in the following logical order:
- #
- # SelectIt(ProcID,PtorRect)
- # PointSelect(Pt,RelToWindow)
- # RectSelect(Rect,RelToWindow)
- # HereToStartSelect()
- # HereToEndSelect()
- # SelectAll()
- #
- # Copyright Apple Computer, Inc. 1985-1990
- # All rights reserved
- #
- #========================================================================
- # History:
- #
- #########################################################################
-
-
- #########################################################################
- # SelectIt(ProcID,PtorRect)
- #========================================================================
- # Author: Su Quek (x48884)
- #
- # Description: This routine performs multiple selection tests :
- #
- # #1 Selects a point.
- # #2 Selects everything within a rectangle.
- # #3 Selects everything from the current position to the
- # top of the file.
- # #4 Selects everything from the current position to the
- # bottom of the file.
- # #5 Selects the entire file, i.e. everything from the
- # top of the file to the bottom.
- #
- # Parameters: ProcID - holds the procedure number
- # PtorRect - holds Pt or Rect coordinates
- #
- # Returns: 0 - encountered an input error. ProcID not one of the choices or
- # format of the PtorRect has an incorrect number of elements.
- #
- # Examples: SelectIt(3,PtorRect)
- #
- # Assumptions: Ruler is not shown
- #========================================================================
- # History:
- #
- #########################################################################
- TASK SelectIt(ProcID,PtorRect) begin
-
- # Point is a list of 2 numbers which gives the x-y coordinates of the point
- # Rect is a list of 4 numbers which gives the left, top, right and bottom coordinates of the rect
-
- if (card(PtorRect) = 4) begin # PtorRect is a list of 4 numbers
- xcoord := PtorRect[1]; # just for this test, take first 2 numbers as the point coords.
- ycoord := PtorRect[2];
- Point:= {xcoord,ycoord};
- Rect := PtorRect;
- end;
- else if (not (card(PtorRect) = 2) or (card(PtorRect) = 4)) begin # PtorRect not a Point or a Rect
- println 'PtorRect must be either a list of 2 numbers (in the case of a point) or';
- println ' a list of 4 numbers (in the case of a rectangle)';
- return (0);
- end;
-
- # Select a Task according to the ProcID
- if (ProcID = 1) begin
- PointSelect (Point);
- end;
- else if (ProcID = 2) begin
- RectSelect (Rect);
- end;
- else if (ProcID = 3) begin
- HereToStartSelect ();
- end;
- else if (ProcID = 4) begin
- HereToEndSelect ();
- end;
- else if (ProcID = 5) begin
- SelectAll ();
- end;
- else begin
- println ProcID, ' is not one of the choices';
- return (0);
- end;
- end;
-
- #########################################################################
- # PointSelect (pPointList,pRelToWindow, pSpecifier)
- #========================================================================
- # Author: SMQ
- # Description: This routine moves the mouse to the location specified
- # by pPointList and clicks to select the point.
- # Parameters: pPointList - List - holds the x-y coordinates of the point
- # pRelToWindow - 1 - coords are relative to the window
- # 0 - coords are absolutes, with respect
- # to the screen.
- # pSpecifier - Enables caller to specify the window the move
- # will be relative to. (0 = document window)
- # Returns: what MoveRelativeToWindow() or MoveMouse() return
- # Examples: PointSelect ({120,100},1, 0)
- # Assumptions:
- #========================================================================
- # History:
- # KTA 12/1/93 Changed calls to MoveRelativeToWindow(), MoveMouse() so they
- # can handle logging the click (bug # 1121663)
- # KTA 12/1/93 Added pSpecifier input parameter and return value and changed
- # the name of the paramters.
- #########################################################################
- TASK PointSelect (pPointList,pRelToWindow := 1, pSpecifier := 1)
- begin
- returnVal := 0; # Init ReturnVal
- if (pRelToWindow) # Relative To window
- returnVal := MoveRelativeToWindow (pPointList[1],pPointList[2],pSpecifier,2);
- else # Absolute coordinates
- returnVal := MoveMouse (pPointList[1],pPointList[2],1,2);
-
- return(returnVal);
- end;
-
- #########################################################################
- # RectSelect (Rect,RelToWindow)
- #========================================================================
- # Author: SMQ
- # Description: This routine selects the rectangle specified by Rect.
- # It moves the mouse to the location specified by the
- # first 2 elements in Rect and everything up to the
- # location specified by the next 2 elements.
- # Parameters: Rect - holds the left, top, right and bottom
- # coordinates of the rect.
- # RelToWindow - 1 - coords are relative to the window
- # 0 - coords are absolutes, with respect
- # to the screen.
- # Returns: Nothing
- # Examples: RectSelect (Rect,1)
- # Assumptions: Ruler is not shown
- #========================================================================
- # History:
- #
- #########################################################################
- TASK RectSelect (Rect,RelToWindow := 1) begin
- prev_speed := mouseSpeed(5); # slow down the mouse and save previous mouse speed
- if (RelToWindow = 1) begin
- MoveRelativeToWIndow (Rect[1],Rect[2],1);
- click;
- MoveMouse (Rect[3]-Rect[1],Rect[4]-Rect[2],0,1);
- end;
- else begin # Relative to screen as opposed to window
- MoveMouse (Rect[1],Rect[2],1,0);
- click;
- MoveMouse (Rect[3],Rect[4],1,1);
- end;
- mouseSpeed(prev_speed); # reset the mouse speed to original
- end;
-
- #########################################################################
- # HereToStartSelect()
- #========================================================================
- # Author: SMQ
- # Description: This routine selects everything from the current
- # position to the start (Top) of the file.
- # Parameters: None
- # Returns: Nothing
- # Examples: HereToStartSelect()
- # Assumptions: Ruler is not shown, coordinates used are relative
- # to the window, as opposed to the screen.
- #========================================================================
- # History:
- #
- #########################################################################
- TASK HereToStartSelect() begin
- ScrollBarList := GetVHScrollBars(); # Save current position of scrollbar
- Vertical := ScrollBarList[1].s;
-
- Vertical_X := Vertical[1];
- Vertical_Y := Vertical[2];
-
- ScrollWindow('V',0,1); # Scroll to the top of file
-
- pressKey k:{ shiftKey }; # Select from current position to top of file
- MoveRelativeToWindow (5,30,1);
- click;
- releaseKey k:{ shiftKey };
-
- ScrollWindow('V',Vertical_X,Vertical_Y); # Scroll back to original position
- end;
-
- #########################################################################
- # HereToEndSelect()
- #========================================================================
- # Author: SMQ
- # Description: This routine selects everything from the current
- # position to the end (Bottom) of the file.
- # Parameters: None
- # Returns: Nothing
- # Examples: HereToEndSelect()
- # Assumptions: Ruler is not shown, coordinates used are relative
- # to the window, as opposed to the screen.
- #========================================================================
- # History:
- #
- #########################################################################
- TASK HereToEndSelect() begin
- ScrollBarList := GetVHScrollBars(); # Save current position of scrollbar
- Vertical := ScrollBarList[1].s;
-
- Vertical_X := Vertical[1];
- Vertical_Y := Vertical[2];
-
- ScrollWindow('V',1,1); # Scroll to the bottom of file
-
- pressKey k:{ shiftKey }; # Select from current position to bottom of file
- match [window o:1 r:?Rect];
- MoveRelativeToWindow (Rect[3]-Rect[1]-20,Rect[4]-Rect[2]-30,1);
- click;
- releaseKey k:{ shiftKey };
-
- ScrollWindow('V',Vertical_X,Vertical_Y); # Scroll back to original position
- end;
-
- #########################################################################
- # SelectAll()
- #========================================================================
- # Author: SMQ
- # Description: This routine selects everything from the top of the
- # frontmost window to the bottom.
- # Parameters: None
- # Returns: Nothing
- # Examples: SelectAll()
- # Assumptions: Ruler is not shown, coordinates used are relative
- # to the window, as opposed to the screen.
- #========================================================================
- # History:
- #
- #########################################################################
- TASK SelectAll() begin
-
- # see if Select All menu item is there - if so, use it
- theMenuItem := match [menuItem t:'Select All']!;
- if (theMenuItem) begin
- if (theMenuItem.e) begin
- theMenuName := theMenuItem.m;
- theMenuName := theMenuName.t;
- if (SelectMenuItem('Select All',theMenuName))
- return(1); # just return to abort routine
- end;
- end;
-
- # if we get to here, there was no 'Select All' menu item or it couldn't
- # be selected - at this point, do it manually.
- ScrollBarList := GetVHScrollBars(); # Save current position of scrollbar
- Vertical := ScrollBarList[1].s;
-
- Vertical_X := Vertical[1];
- Vertical_Y := Vertical[2];
-
- ScrollWindow('V',0,1); # Scroll to the top of file
- MoveRelativeToWindow (5,30,1);
- click;
- ScrollWindow('V',1,1); # Scroll to the bottom of file
-
- pressKey k:{ shiftKey }; # Select from top to bottom of file
- match [window o:1 r:?Rect];
- MoveRelativeToWindow (Rect[3]-Rect[1]-20,Rect[4]-Rect[2]-30,1);
- click;
- releaseKey k:{ shiftKey };
-
- ScrollWindow('V',Vertical_X,Vertical_Y); # Scroll back to original position
- end;
-